class SlaInstanceController < ApplicationController

  #def create_instance
  #  @name = params[:names]
  #  @instances = params[:instances]
  #  @memsize = params[:memsize]
  #  @disksize = params[:disksize]
  #  @type = params[:type]
  #  @service = params[:service]
  #  @app_starttime = params[:app_starttime]
  #  @app_stoptime =params[:app_stoptime]
  #  @monthmode= params[:monthmode]
  #  @instancemode= params[:instancemode]
  #  @price=params[:price]
  #  @fine= params[:fine]
  #  puts "@app_starttime=#{@app_starttime}"
  #  puts "@app_stoptime=#{@app_stoptime}"
  #  puts "@disksize=#{@disksize}"
  #  puts "@fine=#{@fine}"
  #  puts "@type=#{@type}"
  #  puts "@monthmode=#{@monthmode}"
  #
  #
  #  if @name.blank?                                        #判断输入是否不满足要求
  #    flash[:alert] = I18n.t('apps.controller.name_blank')
  #  elsif @instances.blank?
  #    flash[:alert] = I18n.t('apps.controller.instances_blank')
  #  elsif @memsize.blank?
  #    flash[:alert] = I18n.t('apps.controller.memsize_blank')
  #  elsif @disksize.blank?
  #    flash[:alert] = I18n.t('apps.controller.disksize_blank')
  #  elsif @type.blank?
  #    flash[:alert] = I18n.t('apps.controller.type_blank')
  #  elsif @service.blank?
  #    flash[:alert] = I18n.t('apps.controller.service_blank')
  #  elsif @app_starttime.blank?
  #    flash[:alert] = I18n.t('apps.controller.app_starttime_blank')
  #  elsif @app_stoptime.blank?
  #    flash[:alert] = I18n.t('apps.controller.app_stoptime_blank')
  #                                                         #elsif (@app_starttime=~ /^(#{/[1-9]\d\d\d/}\.#{/0?[1-9]|1[12]/}\.#{/0?[1-9]|[12]\d|3[01]/}) (#{/[01]?[1-9]|2[0-4]/}:#{/[0-5]\d/}:#{/[0-5]\d/})$/).nil?
  #                                                         #  flash[:alert] = I18n.t('sla_instances.model.app_starttime_invalid')
  #                                                         #elsif (@app_stoptime=~ /^(#{/[1-9]\d\d\d/}\.#{/0?[1-9]|1[12]/}\.#{/0?[1-9]|[12]\d|3[01]/}) (#{/[01]?[1-9]|2[0-4]/}:#{/[0-5]\d/}:#{/[0-5]\d/})$/).nil?
  #                                                         #  flash[:alert] = I18n.t('sla_instances.model.app_stoptime_invalid')
  #  elsif  (DateTime.parse(@app_starttime).to_i)>(DateTime.parse(@app_stoptime).to_i)
  #    flash[:alert] = I18n.t('sla_instances.model.time_no_match')
  #  elsif  @monthmode.blank?&& @instancemode.blank?
  #    flash[:alert] = I18n.t('apps.controller.mode_blank')
  #  elsif  @monthmode&&@instancemode
  #    flash[:alert] = I18n.t('apps.controller.mode_more')
  #  elsif  @price.blank?
  #    flash[:alert] = I18n.t('apps.controller.price_blank')
  #  elsif  @fine.blank?
  #    flash[:alert] = I18n.t('apps.controller.fine_blank')     # 只能包括数字和小数点的正则表达式
  #
  #    #elsif  (@price=~ /^[0-9]{1}([0-9]|[.])*$/).nil
  #    #  flash[:alert] = I18n.t('apps.controller.price_match')
  #    #elsif  (@fine=~ /^[0-9]{1}([0-9]|[.])*$/).nil
  #    #  flash[:alert] = I18n.t('apps.controller.fine_match')
  #  else        #满足情况，上传
  #    begin
  #      @name = @name.strip.downcase
  #      framework, runtime = @type.split("/")
  #      if  @monthmode
  #        @pricing_mode="month"
  #      else
  #        @pricing_mode="instance"
  #      end
  #
  #      slainstance = SlaInstance.new(@cf_client)
  #      begin
  #        sla_instance_info = slainstance.find(@name)
  #      rescue
  #        sla_template_info = nil
  #      end
  #      if  sla_instance_info.nil?
  #        slainstance.create(@name, @instances, @memsize,@disksize, framework, runtime, @service,@app_starttime,@app_stoptime,@price,@fine,@pricing_mode)        #创建app
  #        sla_instance_info = slainstance.find(@name)
  #        puts"slainstance_info=#{sla_instance_info}"
  #        @new_sla_instance = [] << sla_instance_info
  #        puts"@new_sla_template=#{sla_instance_info}"
  #        flash[:notice] = I18n.t('sla_instances.controller.sla_created', :name => @name)
  #      else
  #        flash[:alert] = I18n.t('sla_instances.controller.already_exists')
  #      end
  #
  #    rescue Exception => ex
  #      flash[:alert] = ex.message
  #    end
  #  end
  #  respond_to { |format|
  #    format.html { redirect_to sla_templates_info_url }
  #    format.js { flash.discard }
  #
  #  }
  #end
  #
  #
  #def delete_instance
  #
  #
  #  @name = params[:name]
  #  puts "delete name=#{@name}"
  #  if @name.blank?
  #    flash[:alert] = I18n.t('sla_instances.controller.name_blank')
  #  else
  #    begin
  #      @name = @name.strip
  #      sla_instance = SlaInstance.new(@cf_client)
  #
  #      sla_instance.delete(@name)
  #      puts"delete :name=#{@name}"
  #      flash[:notice] = I18n.t('sla_instances.controller.sla_deleted', :name => @name)
  #    rescue Exception => ex
  #      flash[:alert] = ex.message
  #    end
  #  end
  #  respond_to do |format|
  #    format.html { redirect_to sla_templates_info_url }
  #    format.js { flash.discard }
  #  end
  #end
  #
  #
  #def show
  #  @name = params[:name]
  #  if @name.blank?
  #    flash[:alert] = I18n.t('sla_instances.controller.name_blank')
  #    redirect_to sla_templates_info_url
  #  else
  #    begin
  #      @name = @name.strip
  #      slainstance = SlaInstance.new(@cf_client)
  #      @sla_instance_info = slainstance.find(@name)
  #
  #      puts"@sla_instance_info=#{@sla_instance_info}"
  #      #@sla_instance_info = [] << sla_instance_info
  #
  #      @memsize = @sla_instance_info[:memsize]
  #      @disksize = @sla_instance_info[:disksize]
  #      @instances = @sla_instance_info[:instances]
  #      @framework=@sla_instance_info[:framework]
  #      @runtime=@sla_instance_info[:runtime]
  #      @service = @sla_instance_info[:service]
  #      @app_starttime = @sla_instance_info[:app_starttime]
  #      @app_stoptime =@sla_instance_info[:app_stoptime]
  #      @price=@sla_instance_info[:price]
  #      @fine=@sla_instance_info[:fine]
  #      @fine=@sla_instance_info[:fine]
  #      @pricing_mode=@sla_instance_info[:pricing_mode]
  #      puts "@instances=#{@memsize}"
  #      puts "@instances=#{@instances}"
  #
  #    rescue CloudFoundry::Client::Exception::NotFound => ex
  #      flash[:alert] = ex.message
  #      redirect_to sla_templates_info_url
  #    rescue Exception => ex
  #      flash[:alert] = ex.message
  #    end
  #  end
  #end


end
